package com.yuqian.JavaSe.socket.chat;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.Socket;
import java.net.UnknownHostException;

import com.yuqian.JavaSe.util.date.TimeUtil;

public class ClientChatOne {
	public static void main(String[] args) throws UnknownHostException, IOException {
		//客户端申请连接
		System.out.println("客户端申请连接：----------");
		Socket client = new Socket("127.0.0.1", 9999);
		System.out.println("当前时间"+TimeUtil.getCurrentTime());
		
		BufferedReader bf =new BufferedReader(new InputStreamReader(client.getInputStream()));
		//读一行服务器数据
		String msg =bf.readLine();
		while(!msg.endsWith("ex")) {
			System.out.println("服务端对客户端说："+msg);
			msg =bf.readLine();
		}
		System.out.println("客户端关闭！！！");
		bf.close();
		client.close();
	}
}
